package com.zhouyibike.uu.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zhouyibike.uu.R;
import com.zhouyibike.uu.entity.ZhinanResult;
import com.zhouyibike.uu.ui.activity.web.TotalWebActivity;

import java.util.List;

/**
 * Created by cc on 2017/5/24.
 */

public class ZhinanAdapter extends BaseAdapter {
    private Context context;
    private List<ZhinanResult.DataBean> list;

    public ZhinanAdapter(Context context, List<ZhinanResult.DataBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        convertView= LayoutInflater.from(context).inflate(R.layout.item_zhinan,null);
        TextView textView= (TextView) convertView.findViewById(R.id.zhinam_text);
        convertView.setTag(list.get(position).getUrl());
        textView.setText(list.get(position).getTitle());
        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(context, TotalWebActivity.class);
                intent.putExtra("title",list.get(position).getTitle());
                intent.putExtra("url",list.get(position).getUrl());
                context.startActivity(intent);
            }
        });
        return convertView;
    }
}
